The dictionary of Smile is opened by selecting "Smile dictionary" in the Apple menu.
Below is given a summary of the dictionary, which is easier to handle than the complete dictionary itself. Refer to the dictionary for the syntax of any command, and for the complete list.
The first four sections below cover functions or commands which can be used in any general AppleScript context.
The last sections cover topics specifically intended to handle Smile's objects (windows, dialog boxes ...).
Remote script handling
• execute : run the script contained in a script window
Sample
----------------------------
execute window "My first script" --> returns the value returned by the script
----------------------------
• check syntax : check syntax of a script window
Sample
----------------------------
check syntax window "My first script"
----------------------------
• do script : execute a script
Sample
----------------------------
set nSamples to (do script (AskUser("Enter formula for # of samples
:", "")))
----------------------------
Above script allows entering a formula (for instance,
"100+12*9"), which will be evaluated by "do script".
AppleScript enhancements
• display : return the direct object as a string
Sample
----------------------------
display (get class of window 1)
----------------------------
• change : replace all occurences of a substring in a document
Sample
----------------------------
change "a" into "A" in window 2
-- {x, y} x = number of changes made, y = number of characters in window 2
----------------------------
Note : "change" works on a document, while "replace", a command of the Satimage osax, works on strings.
• extract column : extract a column out of a table
Comments
The table is supposed to be tab-separated (), with rows separated by carriage return characters (). The result is returned as a list separated by carriage return characters (). You can also obtain the result "as list".
Sample
----------------------------
extract column 2 in theTable as list
----------------------------
• remote info for : locate an alias on the network
Sample
----------------------------
remote info for alias theAliasFileAlias
----------------------------
Navigation services
The commands below use the Navigation Services interface.
• navchoose file : choose files
Caution ! Unlike the standard "choose file", this command returns a list.
• navchoose folder : choose folder
• navask save : prompt for save
• navnew file : get a new file specification
Clipboard commands
• undo
• cut
• copy
• paste
The clipboard commands are window-specific. Each window has its own undo. So, these commands are to be sent to windows:
----------------------------
tell window 1 to undo
----------------------------
Events sent automatically by Smile
• prepare : event sent by the application when an object is created
• do menu : event sent by the application when a menu item is selected
• click in : event generated by a click in an object
• drop : event generated by dropping
• export : return a description for the object dragged
Summary of Smile object classes
• Class basic object : generic class which has the properties owned by each object
Properties:
class type
name
id integer
container
bounds
path name
visible
script
want idle
properties
• Class application : (inherits from basic object) the application program
Elements:
text window
script window
dialog
menu
menu command
Properties:
creator type
cursor
screen bounds
extensions path
user folder
dictionary
modifiers
clipboard
• Class window : (inherits from basic object)
• Class text window : (inherits from window)
Elements:
character
text
international text
Properties:
selection
line width
console
store undo
update screen
• Class script window : (inherits from text window)
• Class character :
Properties:
text size
text font
text color
style text
• Class button : (inherits from agent)
• Class menu :
Elements:
menu item
Properties:
name
enabled
• Class menu item :
Properties:
name
enabled
checked
modifiers
shortcut
Text suite - Smile as a scriptable text editor
When refering to a substring of text contained in a Smile text document (either to read it, or to overwrite it), you can use the following descriptors : character, word, line, paragraph, text / string.
Note the use of line and of paragraph. Paragraph refers to a string terminated by a carriage return, while line refers to a line as wrapped in the window.
By default, these descriptors return lists of strings, like AppleScript does :
----------------------------
words 1 thru 2 of "Smile dictionary"
----------------------------
will [make AppleScript] return {"Smile", "dictionary"}, while :
----------------------------
words 1 thru 2 of window 1
----------------------------
will [make Smile] return {"Smile", "dictionary"}.
Now, you can coerce these expressions, either to list to get the offsets of the ends of the text chunk, or to text to get its contents. You can also coerce them into styled text, to get the text and its style altogether in one variable.
----------------------------
words 1 thru 2 of window 1 as text
----------------------------
-- "Smile Dictionary"
----------------------------
words 1 thru 2 of window 1 as list
----------------------------
-- {0, 16}
----------------------------
set theText to words 1 thru 2 of window 1 as styled text
----------------------------
-- "Smile Dictionary"
The variable 'theText' contains styled text, which can be copied into another text window.
The selection of a text window returns a list. It can also be coerced to text or to styled text.
Similarly, by default, the result of a every expression (including possibly a whose clause) is a list of strings.
These descriptors can be used to specify a piece of text according to its position in the window. Coerce it to list if you want the offsets of its ends.
----------------------------
paragraph after words 1 thru 2 of window 1
----------------------------
-- ""
----------------------------
paragraph after words 1 thru 2 of window 1 as list
----------------------------
-- {17, 18}
Use the 'set' operator to edit the text:
----------------------------
set paragraph after words 1 thru 2 of window 1 to "hello"
• If you control-click, or use the "Help" key, when one of the verbs of the Smile dictionary is selected, this will open the Smile dictionary and scroll it so as to put the selected verb in view.